<%--
  Created by IntelliJ IDEA.
  User: 10171225
  Date: 2016/3/4
  Time: 9:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>"/>
    <title>修改密码</title>
    <script src="static/javascript/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" language="JavaScript">
        $(document).ready(function(){
            $("#editPasswordSubmit").click(function () {
                var map = {
                    "旧密码": $("#oldPassword"),
                    "新密码": $("#newPassword"),
                    "再次输入新密码": $("#newPasswordAgain")
                }
                if($.judgeNotNull(map) == false){
                    return false;
                }
                if($("#newPassword").val() != $("#newPasswordAgain").val()) {
                    alert("两次密码输入不一致！");
                    return;
                }
                $.ajax({
                    type : 'get',
                    contentType:"application/json;charset=utf-8",
                    url : 'user/editPassword',
                    dataType : 'json',
                    cache: false,
                    timeout: 5000,
                    async: false,
                    data: {
                        "oldPassword": encodeURI($("#oldPassword").val()),
                        "newPassword": encodeURI($("#newPassword").val())
                    },
                    success: function(result){
                        alert(result);
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert("ajax异常，请联系管理员！");
                    }
                });
            });
        });
    </script>
</head>
<body>
<div>
    <table>
        <tr>
            <th>旧密码：</th>
            <td><input type="password" id="oldPassword" name="oldPassword"/></td>
        </tr>
        <tr>
            <th>新密码：</th>
            <td><input type="password" id="newPassword" name="newPassword"/></td>
        </tr>
        <tr>
            <th>再次输入新密码：</th>
            <td><input type="password" id="newPasswordAgain" name="newPasswordAgain"/></td>
        </tr>
        <tr>
            <th></th>
            <td><button name="submit" id="editPasswordSubmit">修改密码</button></td>
        </tr>
    </table>
</div>
</body>
</html>
